/*     */ package com.zimbra.qa.unittest;
/*     */ 
/*     */ import com.google.common.collect.Lists;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.soap.SoapFaultException;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.auth.AuthContext.Protocol;
/*     */ import com.zimbra.cs.account.soap.SoapProvisioning;
/*     */ import com.zimbra.soap.admin.message.AddAccountAliasRequest;
/*     */ import com.zimbra.soap.admin.message.AddAccountAliasResponse;
/*     */ import com.zimbra.soap.admin.message.AddDistributionListAliasRequest;
/*     */ import com.zimbra.soap.admin.message.AddDistributionListAliasResponse;
/*     */ import com.zimbra.soap.admin.message.CreateAccountRequest;
/*     */ import com.zimbra.soap.admin.message.CreateAccountResponse;
/*     */ import com.zimbra.soap.admin.message.CreateCalendarResourceRequest;
/*     */ import com.zimbra.soap.admin.message.CreateCalendarResourceResponse;
/*     */ import com.zimbra.soap.admin.message.CreateDistributionListRequest;
/*     */ import com.zimbra.soap.admin.message.CreateDistributionListResponse;
/*     */ import com.zimbra.soap.admin.message.DeleteAccountRequest;
/*     */ import com.zimbra.soap.admin.message.DeleteAccountResponse;
/*     */ import com.zimbra.soap.admin.message.DeleteCalendarResourceRequest;
/*     */ import com.zimbra.soap.admin.message.DeleteCalendarResourceResponse;
/*     */ import com.zimbra.soap.admin.message.DeleteDistributionListRequest;
/*     */ import com.zimbra.soap.admin.message.DeleteDistributionListResponse;
/*     */ import com.zimbra.soap.admin.message.GetAccountRequest;
/*     */ import com.zimbra.soap.admin.message.GetAccountResponse;
/*     */ import com.zimbra.soap.admin.message.GetCalendarResourceRequest;
/*     */ import com.zimbra.soap.admin.message.GetCalendarResourceResponse;
/*     */ import com.zimbra.soap.admin.message.GetDistributionListRequest;
/*     */ import com.zimbra.soap.admin.message.GetDistributionListResponse;
/*     */ import com.zimbra.soap.admin.message.GetMailboxRequest;
/*     */ import com.zimbra.soap.admin.message.GetMailboxResponse;
/*     */ import com.zimbra.soap.admin.message.GrantRightRequest;
/*     */ import com.zimbra.soap.admin.message.GrantRightResponse;
/*     */ import com.zimbra.soap.admin.message.ModifyAccountRequest;
/*     */ import com.zimbra.soap.admin.message.ModifyAccountResponse;
/*     */ import com.zimbra.soap.admin.message.ModifyCalendarResourceRequest;
/*     */ import com.zimbra.soap.admin.message.ModifyCalendarResourceResponse;
/*     */ import com.zimbra.soap.admin.message.ModifyDistributionListRequest;
/*     */ import com.zimbra.soap.admin.message.ModifyDistributionListResponse;
/*     */ import com.zimbra.soap.admin.message.RemoveAccountAliasRequest;
/*     */ import com.zimbra.soap.admin.message.RemoveAccountAliasResponse;
/*     */ import com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest;
/*     */ import com.zimbra.soap.admin.message.RemoveDistributionListAliasResponse;
/*     */ import com.zimbra.soap.admin.message.RenameAccountRequest;
/*     */ import com.zimbra.soap.admin.message.RenameAccountResponse;
/*     */ import com.zimbra.soap.admin.message.RenameCalendarResourceRequest;
/*     */ import com.zimbra.soap.admin.message.RenameCalendarResourceResponse;
/*     */ import com.zimbra.soap.admin.message.RenameDistributionListRequest;
/*     */ import com.zimbra.soap.admin.message.RenameDistributionListResponse;
/*     */ import com.zimbra.soap.admin.type.AccountInfo;
/*     */ import com.zimbra.soap.admin.type.Attr;
/*     */ import com.zimbra.soap.admin.type.CacheEntryType;
/*     */ import com.zimbra.soap.admin.type.CalendarResourceInfo;
/*     */ import com.zimbra.soap.admin.type.CalendarResourceSelector;
/*     */ import com.zimbra.soap.admin.type.DistributionListInfo;
/*     */ import com.zimbra.soap.admin.type.DistributionListSelector;
/*     */ import com.zimbra.soap.admin.type.EffectiveRightsTargetSelector;
/*     */ import com.zimbra.soap.admin.type.GranteeSelector;
/*     */ import com.zimbra.soap.admin.type.GranteeSelector.GranteeBy;
/*     */ import com.zimbra.soap.admin.type.MailboxByAccountIdSelector;
/*     */ import com.zimbra.soap.admin.type.RightModifierInfo;
/*     */ import com.zimbra.soap.type.AccountSelector;
/*     */ import com.zimbra.soap.type.GranteeType;
/*     */ import com.zimbra.soap.type.TargetBy;
/*     */ import com.zimbra.soap.type.TargetType;
/*     */ import java.util.List;
/*     */ import junit.framework.TestCase;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TestDomainAdmin
/*     */   extends TestCase
/*     */ {
/*  96 */   private SoapProvisioning adminSoapProv = null;
/*     */   private static final String ADMINISTRATOR_DOMAIN = "testadmin.domain";
/*     */   private static final String ADMINISTERED_DOMAIN = "administered.domain";
/*     */   private static final String DIFFERENT_DOMAIN = "diff.domain";
/*     */   private static final String DOMADMIN = "domadmin@testadmin.domain";
/*     */   private static final String TARGET_ACCT = "targetacct@administered.domain";
/*     */   private static final String TARGET_ACCT_RENAMED = "targetacctrenamed@administered.domain";
/*     */   private static final String TARGET_CALRES = "targetroom@administered.domain";
/*     */   private static final String TARGET_CALRES2 = "targetroom2@administered.domain";
/*     */   private static final String TARGET_CALRES_RENAMED = "targetroomrenamed@administered.domain";
/*     */   private static final String TARGET_DL = "targetdl@administered.domain";
/*     */   private static final String TARGET_DL2 = "targetdl2@administered.domain";
/*     */   private static final String TARGET_DL_RENAMED = "targetdlrenamed@administered.domain";
/*     */   private static final String DIFF_ACCT = "diffacct@diff.domain";
/*     */   private static final String DIFF_ACCT2 = "diffacct2@diff.domain";
/*     */   private static final String DIFF_CALRES = "diffroom@diff.domain";
/*     */   private static final String DIFF_CALRES2 = "diffroom2@diff.domain";
/*     */   private static final String DIFF_DL = "diffdl@diff.domain";
/*     */   private static final String DIFF_DL2 = "diffdl2@diff.domain";
/*     */   private static final String ALIAS_FOR_TARGET_DL = "alias_4_targetdl@administered.domain";
/*     */   private static final String ALIAS_FOR_TARGET_ACCT = "alias_4_targetacct@administered.domain";
/*     */   private static final String ALIAS_FOR_TARGET_ACCT2 = "alias_4_targetacct2@administered.domain";
/*     */   
/*     */   public void init() throws Exception
/*     */   {
/* 121 */     oneTimeTearDown();
/*     */   }
/*     */   
/*     */   public void oneTimeTearDown() {
/* 125 */     ZimbraLog.test.info("in TestDomainAdmin oneTimeTearDown");
/*     */   }
/*     */   
/*     */   public void setUp() throws Exception
/*     */   {
/* 130 */     if (!TestUtil.fromRunUnitTests) {
/* 131 */       TestUtil.cliSetup();
/*     */     }
/* 133 */     tearDown();
/* 134 */     TestJaxbProvisioning.ensureDomainExists("administered.domain");
/* 135 */     TestJaxbProvisioning.ensureDomainExists("testadmin.domain");
/* 136 */     TestJaxbProvisioning.ensureDomainExists("diff.domain");
/*     */   }
/*     */   
/*     */   public void tearDown() throws Exception
/*     */   {
/* 141 */     ZimbraLog.test.debug("in TestDomainAdmin tearDown");
/* 142 */     if (this.adminSoapProv == null) {
/* 143 */       this.adminSoapProv = TestUtil.newSoapProvisioning();
/*     */     }
/* 145 */     TestUtil.deleteAccount("targetacct@administered.domain");
/* 146 */     TestUtil.deleteAccount("targetacctrenamed@administered.domain");
/* 147 */     TestUtil.deleteAccount("targetroom@administered.domain");
/* 148 */     TestUtil.deleteAccount("targetroom2@administered.domain");
/* 149 */     TestUtil.deleteAccount("targetroomrenamed@administered.domain");
/* 150 */     TestJaxbProvisioning.deleteDlIfExists("targetdl@administered.domain");
/* 151 */     TestJaxbProvisioning.deleteDlIfExists("targetdl2@administered.domain");
/* 152 */     TestJaxbProvisioning.deleteDlIfExists("targetdlrenamed@administered.domain");
/* 153 */     TestUtil.deleteAccount("domadmin@testadmin.domain");
/* 154 */     TestUtil.deleteAccount("domadmin@testadmin.domain");
/* 155 */     TestUtil.deleteAccount("diffacct@diff.domain");
/* 156 */     TestUtil.deleteAccount("diffacct2@diff.domain");
/* 157 */     TestUtil.deleteAccount("diffroom@diff.domain");
/* 158 */     TestUtil.deleteAccount("diffroom2@diff.domain");
/* 159 */     TestJaxbProvisioning.deleteDlIfExists("diffdl@diff.domain");
/* 160 */     TestJaxbProvisioning.deleteDlIfExists("diffdl2@diff.domain");
/* 161 */     TestJaxbProvisioning.deleteDomainIfExists("administered.domain");
/* 162 */     TestJaxbProvisioning.deleteDomainIfExists("testadmin.domain");
/* 163 */     TestJaxbProvisioning.deleteDomainIfExists("diff.domain");
/*     */   }
/*     */   
/*     */   public String createAdminConsoleStyleDomainAdmin(String domAdminName) throws ServiceException {
/* 167 */     List<Attr> attrs = Lists.newArrayList();
/* 168 */     attrs.add(new Attr("zimbraIsDelegatedAdminAccount", "TRUE"));
/* 169 */     attrs.add(new Attr("zimbraAdminConsoleUIComponents", "accountListView"));
/* 170 */     attrs.add(new Attr("zimbraAdminConsoleUIComponents", "downloadsView"));
/* 171 */     attrs.add(new Attr("zimbraAdminConsoleUIComponents", "DLListView"));
/* 172 */     attrs.add(new Attr("zimbraAdminConsoleUIComponents", "aliasListView"));
/* 173 */     attrs.add(new Attr("zimbraAdminConsoleUIComponents", "resourceListView"));
/* 174 */     attrs.add(new Attr("zimbraAdminConsoleUIComponents", "saveSearch"));
/* 175 */     CreateAccountRequest caReq = new CreateAccountRequest(domAdminName, "test123", attrs);
/* 176 */     CreateAccountResponse caResp = (CreateAccountResponse)this.adminSoapProv.invokeJaxb(caReq);
/* 177 */     assertNotNull("CreateAccountResponse for " + domAdminName, caResp);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 184 */     GranteeSelector grantee = new GranteeSelector(GranteeType.usr, GranteeSelector.GranteeBy.name, domAdminName);
/* 185 */     EffectiveRightsTargetSelector target = new EffectiveRightsTargetSelector(TargetType.domain, TargetBy.name, "administered.domain");
/* 186 */     RightModifierInfo right = new RightModifierInfo("domainAdminConsoleRights");
/* 187 */     GrantRightResponse grResp = (GrantRightResponse)this.adminSoapProv.invokeJaxb(new GrantRightRequest(target, grantee, right));
/* 188 */     assertNotNull("GrantRightResponse for " + right.getValue(), grResp);
/*     */     
/* 190 */     target = new EffectiveRightsTargetSelector(TargetType.global, TargetBy.name, "globalacltarget");
/* 191 */     right = new RightModifierInfo("domainAdminZimletRights");
/* 192 */     grResp = (GrantRightResponse)this.adminSoapProv.invokeJaxb(new GrantRightRequest(target, grantee, right));
/* 193 */     assertNotNull("GrantRightResponse for " + right.getValue(), grResp);
/*     */     
/* 195 */     right = new RightModifierInfo("adminLoginCalendarResourceAs");
/* 196 */     grResp = (GrantRightResponse)this.adminSoapProv.invokeJaxb(new GrantRightRequest(target, grantee, right));
/* 197 */     assertNotNull("GrantRightResponse for " + right.getValue(), grResp);
/*     */     
/* 199 */     this.adminSoapProv.flushCache(CacheEntryType.acl, null);
/* 200 */     return caResp.getAccount().getId();
/*     */   }
/*     */   
/*     */   public static SoapProvisioning getSoapProvisioning(String account, String password) throws ServiceException
/*     */   {
/* 205 */     SoapProvisioning sp = SoapProvisioning.getAdminInstance(true);
/* 206 */     if ((account != null) && (password != null)) {
/* 207 */       sp.soapAdminAuthenticate(account, password);
/*     */     } else {
/* 209 */       sp.soapZimbraAdminAuthenticate();
/*     */     }
/* 211 */     return sp;
/*     */   }
/*     */   
/*     */   public static String soapReason(SoapFaultException sfe) {
/* 215 */     Element fault = sfe.getFault();
/* 216 */     if (null != fault) {
/*     */       try {
/* 218 */         Element reason = fault.getElement("Reason");
/* 219 */         if (null != reason) {
/* 220 */           Element text = reason.getElement("Text");
/* 221 */           if (null != text) {
/* 222 */             return text.getText();
/*     */           }
/* 224 */           return reason.toString();
/*     */         }
/*     */       } catch (ServiceException e) {
/* 227 */         return sfe.getMessage();
/*     */       }
/* 229 */       return fault.toString();
/*     */     }
/* 231 */     return sfe.getMessage();
/*     */   }
/*     */   
/*     */   public static void checkSoapReason(SoapFaultException sfe, String expectedSubstring) {
/* 235 */     String soapReason = soapReason(sfe);
/* 236 */     assertTrue("SoapFault reason '" + soapReason + "' should contain '" + expectedSubstring + "'", soapReason.contains(expectedSubstring));
/*     */   }
/*     */   
/*     */   public void testAccountPassword() throws Exception
/*     */   {
/* 241 */     Account acct = this.adminSoapProv.createAccount("targetacct@administered.domain", "test123", null);
/* 242 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/* 243 */     this.adminSoapProv.authAccount(acct, "test123", AuthContext.Protocol.test);
/* 244 */     assertNotNull("Account for targetacct@administered.domain", acct);
/*     */     
/*     */ 
/* 247 */     this.adminSoapProv.changePassword(acct, "test123", "DelTA4Pa555");
/* 248 */     this.adminSoapProv.checkPasswordStrength(acct, "2ndDelTA4Pa555");
/* 249 */     this.adminSoapProv.setPassword(acct, "2ndDelTA4Pa555");
/*     */     
/* 251 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/*     */     try {
/* 253 */       domAdminSoapProv.changePassword(acct, "DelTA4Pa555", "test123");
/* 254 */       fail("changePassword succeeded when shouldn't");
/*     */     } catch (SoapFaultException sfe) {
/* 256 */       checkSoapReason(sfe, "authentication failed for");
/*     */     }
/*     */     try {
/* 259 */       domAdminSoapProv.checkPasswordStrength(acct, "2ndDelTA4Pa555");
/* 260 */       fail("checkPasswordStrength succeeded in spite of not having checkPasswordStrength right!!");
/*     */     } catch (SoapFaultException sfe) {
/* 262 */       checkSoapReason(sfe, "permission denied: need right: checkPasswordStrength for account");
/*     */     }
/* 264 */     domAdminSoapProv.setPassword(acct, "test123");
/*     */   }
/*     */   
/*     */   public void testGetAccountInDomAdminDomain() throws Exception {
/* 268 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/*     */     
/* 270 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/*     */     
/* 272 */     CreateAccountResponse caResp = (CreateAccountResponse)domAdminSoapProv.invokeJaxb(new CreateAccountRequest("targetacct@administered.domain", "test123"));
/* 273 */     assertNotNull("CreateAccountResponse for targetacct@administered.domain simple as domAdmin", caResp);
/* 274 */     String acctId = caResp.getAccount().getId();
/*     */     
/* 276 */     GetAccountRequest getAcctReq = new GetAccountRequest(AccountSelector.fromName("targetacct@administered.domain"), Boolean.valueOf(true));
/* 277 */     GetAccountResponse getAcctResp = (GetAccountResponse)domAdminSoapProv.invokeJaxb(getAcctReq);
/* 278 */     assertNotNull("GetAccountResponse for targetacct@administered.domain simple as domAdmin", getAcctResp);
/* 279 */     getAcctResp = (GetAccountResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
/* 280 */     assertNotNull("GetAccountResponse for targetacct@administered.domain as domAdmin specifying target acct", getAcctResp);
/*     */     
/* 282 */     GetMailboxRequest gmReq = new GetMailboxRequest(new MailboxByAccountIdSelector(acctId));
/* 283 */     GetMailboxResponse gmResp = (GetMailboxResponse)domAdminSoapProv.invokeJaxb(gmReq);
/* 284 */     assertNotNull("GetMailboxResponse for targetacct@administered.domain simple as domAdmin", gmResp);
/* 285 */     gmResp = (GetMailboxResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(gmReq, acctId);
/* 286 */     assertNotNull("GetMailboxResponse for targetacct@administered.domain as domAdmin specifying target acct", gmResp);
/*     */     
/*     */ 
/* 289 */     AddAccountAliasResponse aaaResp = (AddAccountAliasResponse)domAdminSoapProv.invokeJaxb(new AddAccountAliasRequest(acctId, "alias_4_targetacct@administered.domain"));
/* 290 */     assertNotNull("AddAccountAliasResponse for targetacct@administered.domain simple as domAdmin", aaaResp);
/* 291 */     aaaResp = (AddAccountAliasResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(new AddAccountAliasRequest(acctId, "alias_4_targetacct2@administered.domain"), acctId);
/*     */     
/* 293 */     assertNotNull("AddAccountAliasResponse for targetacct@administered.domain as domAdmin specifying target acct", aaaResp);
/*     */     
/*     */ 
/* 296 */     RemoveAccountAliasResponse daaResp = (RemoveAccountAliasResponse)domAdminSoapProv.invokeJaxb(new RemoveAccountAliasRequest(acctId, "alias_4_targetacct@administered.domain"));
/* 297 */     assertNotNull("RemoveAccountAliasResponse for targetacct@administered.domain simple as domAdmin", daaResp);
/* 298 */     daaResp = (RemoveAccountAliasResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(new RemoveAccountAliasRequest(acctId, "alias_4_targetacct2@administered.domain"), acctId);
/*     */     
/* 300 */     assertNotNull("RemoveAccountAliasResponse for targetacct@administered.domain as domAdmin specifying target acct", daaResp);
/*     */     
/*     */ 
/* 303 */     RenameAccountResponse renAResp = (RenameAccountResponse)domAdminSoapProv.invokeJaxb(new RenameAccountRequest(acctId, "targetacctrenamed@administered.domain"));
/* 304 */     assertNotNull("RenameAccountResponse for targetacct@administered.domain simple as domAdmin", renAResp);
/*     */     
/* 306 */     renAResp = (RenameAccountResponse)domAdminSoapProv.invokeJaxb(new RenameAccountRequest(acctId, "targetacct@administered.domain"));
/* 307 */     assertNotNull("RenameAccountResponse for targetacct@administered.domain as domAdmin specifying target acct", renAResp);
/*     */     
/* 309 */     DeleteAccountRequest delAcctReq = new DeleteAccountRequest(acctId);
/* 310 */     DeleteAccountResponse delAcctResp = (DeleteAccountResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
/* 311 */     assertNotNull("DeleteAccountResponse for targetacct@administered.domain as domAdmin specifying target acct", delAcctResp);
/*     */     try {
/* 313 */       getAcctResp = (GetAccountResponse)domAdminSoapProv.invokeJaxb(getAcctReq);
/* 314 */       fail("GetAccountRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 316 */       checkSoapReason(sfe, "no such account: ");
/*     */     }
/*     */     try {
/* 319 */       getAcctResp = (GetAccountResponse)domAdminSoapProv.invokeJaxb(new GetAccountRequest(AccountSelector.fromId(acctId), Boolean.valueOf(true)));
/*     */       
/* 321 */       fail("GetAccountRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 323 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try {
/* 326 */       getAcctResp = (GetAccountResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
/* 327 */       fail("GetAccountRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 329 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try
/*     */     {
/* 333 */       gmResp = (GetMailboxResponse)domAdminSoapProv.invokeJaxb(gmReq);
/* 334 */       fail("GetMailboxRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 336 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try {
/* 339 */       gmResp = (GetMailboxResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(gmReq, acctId);
/* 340 */       fail("GetMailboxRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 342 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testGetAccountInDiffDomain() throws Exception {
/* 347 */     Account acct = TestJaxbProvisioning.ensureAccountExists("diffacct@diff.domain");
/* 348 */     String acctId = acct.getId();
/* 349 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/*     */     
/* 351 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 352 */     GetAccountRequest getAcctReq = new GetAccountRequest(AccountSelector.fromName("diffacct@diff.domain"), Boolean.valueOf(true));
/*     */     try {
/* 354 */       domAdminSoapProv.invokeJaxb(getAcctReq);
/* 355 */       fail("GetAccountRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 357 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try {
/* 360 */       domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
/* 361 */       fail("GetAccountRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 363 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     
/*     */ 
/* 367 */     getAcctReq = new GetAccountRequest(AccountSelector.fromName("diffacct2@diff.domain"), Boolean.valueOf(true));
/*     */     try {
/* 369 */       domAdminSoapProv.invokeJaxb(getAcctReq);
/* 370 */       fail("GetAccountRequest succeeded for non-existent account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 372 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     
/* 375 */     GetMailboxRequest gmReq = new GetMailboxRequest(new MailboxByAccountIdSelector(acctId));
/*     */     try {
/* 377 */       domAdminSoapProv.invokeJaxb(gmReq);
/* 378 */       fail("GetMailboxRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 380 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try {
/* 383 */       domAdminSoapProv.invokeJaxbOnTargetAccount(gmReq, acctId);
/* 384 */       fail("GetMailboxRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 386 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     
/*     */     try
/*     */     {
/* 391 */       aaaResp = (AddAccountAliasResponse)domAdminSoapProv.invokeJaxb(new AddAccountAliasRequest(acctId, "alias_4_targetacct@administered.domain"));
/* 392 */       fail("AddAccountAliasRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 394 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try {
/* 397 */       aaaResp = (AddAccountAliasResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(new AddAccountAliasRequest(acctId, "alias_4_targetacct2@administered.domain"), acctId);
/*     */       
/* 399 */       fail("AddAccountAliasRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 401 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     
/* 404 */     AddAccountAliasResponse aaaResp = (AddAccountAliasResponse)this.adminSoapProv.invokeJaxb(new AddAccountAliasRequest(acctId, "alias_4_targetacct@administered.domain"));
/* 405 */     assertNotNull("AddAccountAliasResponse for targetacct@administered.domain as FULL ADMIN", aaaResp);
/*     */     try
/*     */     {
/* 408 */       domAdminSoapProv.invokeJaxb(new RemoveAccountAliasRequest(acctId, "alias_4_targetacct@administered.domain"));
/* 409 */       fail("RemoveAccountAliasRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 411 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try
/*     */     {
/* 415 */       domAdminSoapProv.invokeJaxb(new RenameAccountRequest(acctId, "targetacctrenamed@administered.domain"));
/* 416 */       fail("RenameAccountRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 418 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try
/*     */     {
/* 422 */       domAdminSoapProv.invokeJaxb(new DeleteAccountRequest(acctId));
/* 423 */       fail("DeleteAccountRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 425 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testModifyAccountInDomAdminDomain() throws Exception {
/* 430 */     Account acct = TestJaxbProvisioning.ensureAccountExists("targetacct@administered.domain");
/* 431 */     String acctId = acct.getId();
/* 432 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/*     */     
/* 434 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 435 */     ModifyAccountRequest modAcctReq = new ModifyAccountRequest(acctId);
/* 436 */     modAcctReq.addAttr(new Attr("description", "dummy description"));
/* 437 */     ModifyAccountResponse modAcctResp = (ModifyAccountResponse)domAdminSoapProv.invokeJaxb(modAcctReq);
/* 438 */     assertNotNull("ModifyAccountResponse for targetacct@administered.domain simple as domAdmin", modAcctResp);
/* 439 */     modAcctReq = new ModifyAccountRequest(acctId);
/* 440 */     modAcctReq.addAttr(new Attr("description", "another dummy description"));
/* 441 */     modAcctResp = (ModifyAccountResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
/* 442 */     assertNotNull("ModifyAccountResponse for targetacct@administered.domain as domAdmin specifying target acct", modAcctResp);
/* 443 */     DeleteAccountRequest delAcctReq = new DeleteAccountRequest(acctId);
/* 444 */     DeleteAccountResponse delAcctResp = (DeleteAccountResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
/* 445 */     assertNotNull("DeleteAccountResponse for targetacct@administered.domain as domAdmin specifying target acct", delAcctResp);
/*     */     try {
/* 447 */       modAcctResp = (ModifyAccountResponse)domAdminSoapProv.invokeJaxb(modAcctReq);
/* 448 */       fail("ModifyAccountRequest succeeded after delete!");
/*     */     }
/*     */     catch (SoapFaultException sfe)
/*     */     {
/* 452 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try {
/* 455 */       modAcctResp = (ModifyAccountResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
/* 456 */       fail("ModifyAccountRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 458 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     
/*     */     try
/*     */     {
/* 463 */       modAcctResp = (ModifyAccountResponse)this.adminSoapProv.invokeJaxb(modAcctReq);
/* 464 */       fail("ModifyAccountRequest succeeded after delete!");
/*     */     }
/*     */     catch (SoapFaultException sfe) {
/* 467 */       checkSoapReason(sfe, "no such account: ");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testModifyAccountInDiffDomain() throws Exception {
/* 472 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/* 473 */     Account acct = TestJaxbProvisioning.ensureAccountExists("diffacct@diff.domain");
/* 474 */     String acctId = acct.getId();
/*     */     
/* 476 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 477 */     ModifyAccountRequest modAcctReq = new ModifyAccountRequest(acctId);
/* 478 */     modAcctReq.addAttr(new Attr("description", "dummy description"));
/*     */     try {
/* 480 */       domAdminSoapProv.invokeJaxb(modAcctReq);
/*     */     } catch (SoapFaultException sfe) {
/* 482 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try {
/* 485 */       domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
/*     */     } catch (SoapFaultException sfe) {
/* 487 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/* 489 */     DeleteAccountRequest delAcctReq = new DeleteAccountRequest(acctId);
/* 490 */     DeleteAccountResponse delAcctResp = (DeleteAccountResponse)this.adminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
/* 491 */     assertNotNull("DeleteAccountResponse for diffacct@diff.domain as ADMIN specifying target acct", delAcctResp);
/*     */     try
/*     */     {
/* 494 */       domAdminSoapProv.invokeJaxb(modAcctReq);
/* 495 */       fail("ModifyAccountRequest succeeded after delete!");
/*     */     }
/*     */     catch (SoapFaultException sfe)
/*     */     {
/* 499 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */     try {
/* 502 */       domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
/* 503 */       fail("ModifyAccountRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 505 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testGetCalendarResourceInDomAdminDomain() throws Exception {
/* 510 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/*     */     
/* 512 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 513 */     List<Attr> attrs = Lists.newArrayList();
/* 514 */     attrs.add(new Attr("displayName", "testGetCalendarResourceInDomAdminDomain Room 101"));
/* 515 */     attrs.add(new Attr("description", "Room 101 for 50 seats"));
/* 516 */     attrs.add(new Attr("zimbraCalResType", "Location"));
/* 517 */     attrs.add(new Attr("zimbraCalResAutoAcceptDecline", "TRUE"));
/* 518 */     attrs.add(new Attr("zimbraCalResAutoDeclineIfBusy", "TRUE"));
/*     */     
/* 520 */     CreateCalendarResourceResponse caResp = (CreateCalendarResourceResponse)domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest("targetroom@administered.domain", "test123", attrs));
/*     */     
/* 522 */     assertNotNull("CreateCalendarResourceResponse for targetroom@administered.domain simple as domAdmin", caResp);
/* 523 */     String acctId = caResp.getCalResource().getId();
/*     */     
/* 525 */     GetCalendarResourceResponse getAcctResp = (GetCalendarResourceResponse)domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromName("targetroom@administered.domain"), Boolean.valueOf(true)));
/*     */     
/* 527 */     assertNotNull("GetCalendarResourceResponse for targetroom@administered.domain simple as domAdmin", getAcctResp);
/* 528 */     getAcctResp = (GetCalendarResourceResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(new GetCalendarResourceRequest(CalendarResourceSelector.fromName("targetroom@administered.domain"), Boolean.valueOf(true)), acctId);
/*     */     
/*     */ 
/* 531 */     assertNotNull("GetCalendarResourceResponse for targetroom@administered.domain as domAdmin specifying target acct", getAcctResp);
/*     */     
/*     */ 
/*     */ 
/* 535 */     RenameCalendarResourceResponse renAResp = (RenameCalendarResourceResponse)domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, "targetroomrenamed@administered.domain"));
/* 536 */     assertNotNull("RenameCalendarResourceResponse for targetroom@administered.domain simple as domAdmin", renAResp);
/*     */     
/* 538 */     renAResp = (RenameCalendarResourceResponse)domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, "targetroom@administered.domain"));
/* 539 */     assertNotNull("RenameCalendarResourceResponse for targetroom@administered.domain as domAdmin specifying target acct", renAResp);
/*     */     
/*     */ 
/* 542 */     DeleteCalendarResourceRequest delAcctReq = new DeleteCalendarResourceRequest(acctId);
/* 543 */     DeleteCalendarResourceResponse delAcctResp = (DeleteCalendarResourceResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
/* 544 */     assertNotNull("DeleteCalendarResourceResponse for targetroom@administered.domain as domAdmin specifying target acct", delAcctResp);
/*     */     try
/*     */     {
/* 547 */       getAcctResp = (GetCalendarResourceResponse)domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromName("targetroom@administered.domain"), Boolean.valueOf(true)));
/*     */       
/* 549 */       fail("GetCalendarResourceRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 551 */       checkSoapReason(sfe, "no such calendar resource: ");
/*     */     }
/*     */     try {
/* 554 */       getAcctResp = (GetCalendarResourceResponse)domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromId(acctId), Boolean.valueOf(true)));
/*     */       
/* 556 */       fail("GetCalendarResourceRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 558 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/*     */     try {
/* 561 */       getAcctResp = (GetCalendarResourceResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(new GetCalendarResourceRequest(CalendarResourceSelector.fromName("targetroom@administered.domain"), Boolean.valueOf(true)), acctId);
/*     */       
/*     */ 
/* 564 */       fail("GetCalendarResourceRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 566 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testGetCalendarResourceInDiffDomain() throws Exception {
/* 571 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/* 572 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 573 */     List<Attr> attrs = Lists.newArrayList();
/* 574 */     attrs.add(new Attr("displayName", "testGetCalendarResourceInDiffDomain Room 101"));
/* 575 */     attrs.add(new Attr("description", "Room 101 for 50 seats"));
/* 576 */     attrs.add(new Attr("zimbraCalResType", "Location"));
/* 577 */     attrs.add(new Attr("zimbraCalResAutoAcceptDecline", "TRUE"));
/* 578 */     attrs.add(new Attr("zimbraCalResAutoDeclineIfBusy", "TRUE"));
/*     */     try
/*     */     {
/* 581 */       caResp = (CreateCalendarResourceResponse)domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest("diffroom@diff.domain", "test123", attrs));
/*     */       
/* 583 */       fail("CreateCalendarResourceRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 585 */       checkSoapReason(sfe, "permission denied: need right: createCalendarResource for domain");
/*     */     }
/* 587 */     CreateCalendarResourceResponse caResp = (CreateCalendarResourceResponse)this.adminSoapProv.invokeJaxb(new CreateCalendarResourceRequest("diffroom@diff.domain", "test123", attrs));
/*     */     
/* 589 */     assertNotNull("CreateCalendarResourceResponse for diffroom@diff.domain simple as domAdmin", caResp);
/* 590 */     String acctId = caResp.getCalResource().getId();
/*     */     
/* 592 */     GetCalendarResourceRequest getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName("diffroom@diff.domain"), Boolean.valueOf(true));
/*     */     try
/*     */     {
/* 595 */       domAdminSoapProv.invokeJaxb(getAcctReq);
/* 596 */       fail("GetCalendarResourceRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 598 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/*     */     try {
/* 601 */       domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
/* 602 */       fail("GetCalendarResourceRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 604 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/*     */     
/*     */ 
/* 608 */     getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName("diffroom2@diff.domain"), Boolean.valueOf(true));
/*     */     try {
/* 610 */       domAdminSoapProv.invokeJaxb(getAcctReq);
/* 611 */       fail("GetCalendarResourceRequest succeeded for non-existent account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 613 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/*     */     try
/*     */     {
/* 617 */       domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, "targetroomrenamed@administered.domain"));
/* 618 */       fail("RenameCalendarResourceRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 620 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/*     */     try
/*     */     {
/* 624 */       domAdminSoapProv.invokeJaxb(new DeleteCalendarResourceRequest(acctId));
/* 625 */       fail("DeleteCalendarResourceRequest succeeded for account in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 627 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testModifyCalendarResourceInDomAdminDomain() throws Exception {
/* 632 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/* 633 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 634 */     List<Attr> attrs = Lists.newArrayList();
/* 635 */     attrs.add(new Attr("displayName", "testModifyCalendarResourceInDomAdminDomain Room 101"));
/* 636 */     attrs.add(new Attr("description", "Room 101 for 50 seats"));
/* 637 */     attrs.add(new Attr("zimbraCalResType", "Location"));
/* 638 */     attrs.add(new Attr("zimbraCalResAutoAcceptDecline", "TRUE"));
/* 639 */     attrs.add(new Attr("zimbraCalResAutoDeclineIfBusy", "TRUE"));
/*     */     
/* 641 */     CreateCalendarResourceResponse caResp = (CreateCalendarResourceResponse)domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest("targetroom@administered.domain", "test123", attrs));
/*     */     
/* 643 */     assertNotNull("CreateCalendarResourceResponse for targetroom@administered.domain simple as domAdmin", caResp);
/* 644 */     String acctId = caResp.getCalResource().getId();
/*     */     
/* 646 */     ModifyCalendarResourceRequest modAcctReq = new ModifyCalendarResourceRequest(acctId);
/* 647 */     modAcctReq.addAttr(new Attr("description", "dummy description"));
/* 648 */     ModifyCalendarResourceResponse modAcctResp = (ModifyCalendarResourceResponse)domAdminSoapProv.invokeJaxb(modAcctReq);
/* 649 */     assertNotNull("ModifyCalendarResourceResponse for targetroom2@administered.domain simple as domAdmin", modAcctResp);
/* 650 */     modAcctReq = new ModifyCalendarResourceRequest(acctId);
/* 651 */     modAcctReq.addAttr(new Attr("description", "another dummy description"));
/* 652 */     modAcctResp = (ModifyCalendarResourceResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
/* 653 */     assertNotNull("ModifyCalendarResourceResponse for targetroom2@administered.domain as domAdmin specifying target acct", modAcctResp);
/*     */     
/* 655 */     DeleteCalendarResourceRequest delAcctReq = new DeleteCalendarResourceRequest(acctId);
/* 656 */     DeleteCalendarResourceResponse delAcctResp = (DeleteCalendarResourceResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
/* 657 */     assertNotNull("DeleteCalendarResourceResponse for targetroom2@administered.domain as domAdmin specifying target acct", delAcctResp);
/*     */     try
/*     */     {
/* 660 */       modAcctResp = (ModifyCalendarResourceResponse)domAdminSoapProv.invokeJaxb(modAcctReq);
/* 661 */       fail("ModifyCalendarResourceRequest succeeded after delete!");
/*     */     }
/*     */     catch (SoapFaultException sfe)
/*     */     {
/* 665 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/*     */     try {
/* 668 */       modAcctResp = (ModifyCalendarResourceResponse)domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
/* 669 */       fail("ModifyCalendarResourceRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 671 */       checkSoapReason(sfe, "permission denied: can not access account");
/*     */     }
/*     */     
/*     */     try
/*     */     {
/* 676 */       modAcctResp = (ModifyCalendarResourceResponse)this.adminSoapProv.invokeJaxb(modAcctReq);
/* 677 */       fail("ModifyCalendarResourceRequest succeeded after delete!");
/*     */     }
/*     */     catch (SoapFaultException sfe) {
/* 680 */       checkSoapReason(sfe, "no such calendar resource: ");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testModifyCalendarResourceInDiffDomain() throws Exception {
/* 685 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/* 686 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 687 */     List<Attr> attrs = Lists.newArrayList();
/* 688 */     attrs.add(new Attr("displayName", "testModifyCalendarResourceInDiffDomain Room 101"));
/* 689 */     attrs.add(new Attr("description", "Room 101 for 50 seats"));
/* 690 */     attrs.add(new Attr("zimbraCalResType", "Location"));
/* 691 */     attrs.add(new Attr("zimbraCalResAutoAcceptDecline", "TRUE"));
/* 692 */     attrs.add(new Attr("zimbraCalResAutoDeclineIfBusy", "TRUE"));
/*     */     
/* 694 */     CreateCalendarResourceResponse caResp = (CreateCalendarResourceResponse)this.adminSoapProv.invokeJaxb(new CreateCalendarResourceRequest("diffroom@diff.domain", "test123", attrs));
/*     */     
/* 696 */     assertNotNull("CreateCalendarResourceResponse for diffroom@diff.domain as FULL ADMIN", caResp);
/* 697 */     String acctId = caResp.getCalResource().getId();
/*     */     
/* 699 */     ModifyCalendarResourceRequest modAcctReq = new ModifyCalendarResourceRequest(acctId);
/* 700 */     modAcctReq.addAttr(new Attr("description", "dummy description"));
/*     */     try {
/* 702 */       domAdminSoapProv.invokeJaxb(modAcctReq);
/*     */     } catch (SoapFaultException sfe) {
/* 704 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/*     */     try {
/* 707 */       domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
/*     */     } catch (SoapFaultException sfe) {
/* 709 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/* 711 */     DeleteCalendarResourceRequest delAcctReq = new DeleteCalendarResourceRequest(acctId);
/* 712 */     DeleteCalendarResourceResponse delAcctResp = (DeleteCalendarResourceResponse)this.adminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
/* 713 */     assertNotNull("DeleteCalendarResourceResponse for diffroom@diff.domain as ADMIN specifying target acct", delAcctResp);
/*     */     try
/*     */     {
/* 716 */       domAdminSoapProv.invokeJaxb(modAcctReq);
/* 717 */       fail("ModifyCalendarResourceRequest succeeded after delete!");
/*     */     }
/*     */     catch (SoapFaultException sfe)
/*     */     {
/* 721 */       checkSoapReason(sfe, "permission denied: can not access calendar resource ");
/*     */     }
/*     */     try {
/* 724 */       domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
/* 725 */       fail("ModifyCalendarResourceRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 727 */       checkSoapReason(sfe, "permission denied: can not access account ");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testGetDistributionListInDomAdminDomain() throws Exception {
/* 732 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/*     */     
/* 734 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/*     */     
/* 736 */     CreateDistributionListResponse caResp = (CreateDistributionListResponse)domAdminSoapProv.invokeJaxb(new CreateDistributionListRequest("targetdl@administered.domain"));
/* 737 */     assertNotNull("CreateDistributionListResponse for targetdl@administered.domain simple as domAdmin", caResp);
/* 738 */     String dlId = caResp.getDl().getId();
/*     */     
/* 740 */     GetDistributionListRequest getDlReq = new GetDistributionListRequest(DistributionListSelector.fromName("targetdl@administered.domain"));
/*     */     
/* 742 */     GetDistributionListResponse getDlResp = (GetDistributionListResponse)domAdminSoapProv.invokeJaxb(getDlReq);
/* 743 */     assertNotNull("GetDistributionListResponse for targetdl@administered.domain simple as domAdmin", getDlResp);
/*     */     
/*     */ 
/* 746 */     AddDistributionListAliasResponse aaaResp = (AddDistributionListAliasResponse)domAdminSoapProv.invokeJaxb(new AddDistributionListAliasRequest(dlId, "alias_4_targetdl@administered.domain"));
/* 747 */     assertNotNull("AddDistributionListAliasResponse for targetdl@administered.domain simple as domAdmin", aaaResp);
/*     */     
/*     */ 
/* 750 */     RemoveDistributionListAliasResponse daaResp = (RemoveDistributionListAliasResponse)domAdminSoapProv.invokeJaxb(new RemoveDistributionListAliasRequest(dlId, "alias_4_targetdl@administered.domain"));
/* 751 */     assertNotNull("RemoveDistributionListAliasResponse for targetdl@administered.domain simple as domAdmin", daaResp);
/*     */     
/*     */ 
/* 754 */     RenameDistributionListResponse renAResp = (RenameDistributionListResponse)domAdminSoapProv.invokeJaxb(new RenameDistributionListRequest(dlId, "targetdlrenamed@administered.domain"));
/* 755 */     assertNotNull("RenameDistributionListResponse for targetdl@administered.domain simple as domAdmin", renAResp);
/*     */     
/* 757 */     DeleteDistributionListRequest delAcctReq = new DeleteDistributionListRequest(dlId);
/* 758 */     DeleteDistributionListResponse delAcctResp = (DeleteDistributionListResponse)domAdminSoapProv.invokeJaxb(delAcctReq);
/* 759 */     assertNotNull("DeleteDistributionListResponse for targetdl@administered.domain as domAdmin", delAcctResp);
/*     */     try {
/* 761 */       getDlResp = (GetDistributionListResponse)domAdminSoapProv.invokeJaxb(getDlReq);
/* 762 */       fail("GetDistributionListRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 764 */       checkSoapReason(sfe, "no such distribution list:");
/*     */     }
/*     */     try {
/* 767 */       getDlResp = (GetDistributionListResponse)domAdminSoapProv.invokeJaxb(new GetDistributionListRequest(DistributionListSelector.fromId(dlId)));
/*     */       
/* 769 */       fail("GetDistributionListRequest succeeded after delete!");
/*     */     } catch (SoapFaultException sfe) {
/* 771 */       checkSoapReason(sfe, "permission denied: can not access distribution list");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testGetDistributionListInDiffDomain() throws Exception {
/* 776 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/*     */     
/* 778 */     CreateDistributionListResponse caResp = (CreateDistributionListResponse)this.adminSoapProv.invokeJaxb(new CreateDistributionListRequest("diffdl@diff.domain"));
/* 779 */     assertNotNull("CreateDistributionListResponse for diffdl@diff.domain as FULL ADMIN", caResp);
/* 780 */     String dlId = caResp.getDl().getId();
/*     */     
/* 782 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 783 */     GetDistributionListRequest getAcctReq = new GetDistributionListRequest(DistributionListSelector.fromName("diffdl@diff.domain"));
/*     */     try
/*     */     {
/* 786 */       domAdminSoapProv.invokeJaxb(getAcctReq);
/* 787 */       fail("GetDistributionListRequest succeeded for DistributionList in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 789 */       checkSoapReason(sfe, "permission denied: can not access distribution list");
/*     */     }
/*     */     
/*     */ 
/* 793 */     getAcctReq = new GetDistributionListRequest(DistributionListSelector.fromName("diffdl2@diff.domain"));
/*     */     try {
/* 795 */       domAdminSoapProv.invokeJaxb(getAcctReq);
/* 796 */       fail("GetDistributionListRequest succeeded for non-existent DistributionList in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 798 */       checkSoapReason(sfe, "permission denied: can not access distribution list");
/*     */     }
/*     */     
/*     */     try
/*     */     {
/* 803 */       aaaResp = (AddDistributionListAliasResponse)domAdminSoapProv.invokeJaxb(new AddDistributionListAliasRequest(dlId, "alias_4_targetdl@administered.domain"));
/* 804 */       fail("AddDistributionListAliasRequest succeeded for DistributionList in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 806 */       checkSoapReason(sfe, "permission denied: can not access distribution list");
/*     */     }
/*     */     
/* 809 */     AddDistributionListAliasResponse aaaResp = (AddDistributionListAliasResponse)this.adminSoapProv.invokeJaxb(new AddDistributionListAliasRequest(dlId, "alias_4_targetdl@administered.domain"));
/* 810 */     assertNotNull("AddDistributionListAliasResponse for targetdl@administered.domain as FULL ADMIN", aaaResp);
/*     */     try
/*     */     {
/* 813 */       domAdminSoapProv.invokeJaxb(new RemoveDistributionListAliasRequest(dlId, "alias_4_targetdl@administered.domain"));
/* 814 */       fail("RemoveDistributionListAliasRequest succeeded for DistributionList in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 816 */       checkSoapReason(sfe, "permission denied: can not access distribution list");
/*     */     }
/*     */     try
/*     */     {
/* 820 */       domAdminSoapProv.invokeJaxb(new RenameDistributionListRequest(dlId, "targetdlrenamed@administered.domain"));
/* 821 */       fail("RenameDistributionListRequest succeeded for DistributionList in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 823 */       checkSoapReason(sfe, "permission denied: can not access distribution list");
/*     */     }
/*     */     try
/*     */     {
/* 827 */       domAdminSoapProv.invokeJaxb(new DeleteDistributionListRequest(dlId));
/* 828 */       fail("DeleteDistributionListRequest succeeded for DistributionList in other domain!");
/*     */     } catch (SoapFaultException sfe) {
/* 830 */       checkSoapReason(sfe, "permission denied: can not access distribution list");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testModifyDistributionListInDomAdminDomain() throws Exception {
/* 835 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/* 836 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 837 */     List<Attr> attrs = Lists.newArrayList();
/* 838 */     attrs.add(new Attr("displayName", "testModifyDistributionListInDomAdminDomain"));
/*     */     
/* 840 */     CreateDistributionListResponse caResp = (CreateDistributionListResponse)domAdminSoapProv.invokeJaxb(new CreateDistributionListRequest("targetdl@administered.domain", attrs, false));
/*     */     
/* 842 */     assertNotNull("CreateDistributionListResponse for targetdl@administered.domain simple as domAdmin", caResp);
/* 843 */     String dlId = caResp.getDl().getId();
/*     */     
/* 845 */     ModifyDistributionListRequest modDlReq = new ModifyDistributionListRequest(dlId);
/* 846 */     modDlReq.addAttr(new Attr("description", "dummy description"));
/* 847 */     ModifyDistributionListResponse modDlResp = (ModifyDistributionListResponse)domAdminSoapProv.invokeJaxb(modDlReq);
/* 848 */     assertNotNull("ModifyDistributionListResponse for targetdl2@administered.domain simple as domAdmin", modDlResp);
/* 849 */     DeleteDistributionListRequest delDlReq = new DeleteDistributionListRequest(dlId);
/* 850 */     DeleteDistributionListResponse delDlResp = (DeleteDistributionListResponse)domAdminSoapProv.invokeJaxb(delDlReq);
/* 851 */     assertNotNull("DeleteDistributionListResponse for targetdl2@administered.domain as domAdmin", delDlResp);
/*     */     try {
/* 853 */       modDlResp = (ModifyDistributionListResponse)domAdminSoapProv.invokeJaxb(modDlReq);
/* 854 */       fail("ModifyDistributionListRequest succeeded after delete!");
/*     */     }
/*     */     catch (SoapFaultException sfe)
/*     */     {
/* 858 */       checkSoapReason(sfe, "permission denied: can not access distribution list ");
/*     */     }
/*     */     
/*     */     try
/*     */     {
/* 863 */       modDlResp = (ModifyDistributionListResponse)this.adminSoapProv.invokeJaxb(modDlReq);
/* 864 */       fail("ModifyDistributionListRequest succeeded after delete!");
/*     */     }
/*     */     catch (SoapFaultException sfe) {
/* 867 */       checkSoapReason(sfe, "no such distribution list: ");
/*     */     }
/*     */   }
/*     */   
/*     */   public void testModifyDistributionListInDiffDomain() throws Exception {
/* 872 */     String domAdminId = createAdminConsoleStyleDomainAdmin("domadmin@testadmin.domain");
/* 873 */     SoapProvisioning domAdminSoapProv = getSoapProvisioning("domadmin@testadmin.domain", "test123");
/* 874 */     List<Attr> attrs = Lists.newArrayList();
/* 875 */     attrs.add(new Attr("displayName", "testGetDistributionListInDiffDomain Room 101"));
/*     */     
/* 877 */     CreateDistributionListResponse caResp = (CreateDistributionListResponse)this.adminSoapProv.invokeJaxb(new CreateDistributionListRequest("diffdl@diff.domain", attrs, false));
/*     */     
/* 879 */     assertNotNull("CreateDistributionListResponse for diffdl@diff.domain as FULL ADMIN", caResp);
/* 880 */     String dlId = caResp.getDl().getId();
/*     */     
/* 882 */     ModifyDistributionListRequest modAcctReq = new ModifyDistributionListRequest(dlId);
/* 883 */     modAcctReq.addAttr(new Attr("description", "dummy description"));
/*     */     try {
/* 885 */       domAdminSoapProv.invokeJaxb(modAcctReq);
/*     */     } catch (SoapFaultException sfe) {
/* 887 */       checkSoapReason(sfe, "permission denied: can not access distribution list ");
/*     */     }
/* 889 */     DeleteDistributionListRequest delAcctReq = new DeleteDistributionListRequest(dlId);
/* 890 */     DeleteDistributionListResponse delAcctResp = (DeleteDistributionListResponse)this.adminSoapProv.invokeJaxb(delAcctReq);
/* 891 */     assertNotNull("DeleteDistributionListResponse for diffdl@diff.domain as ADMIN", delAcctResp);
/*     */     try {
/* 893 */       domAdminSoapProv.invokeJaxb(modAcctReq);
/* 894 */       fail("ModifyDistributionListRequest succeeded after delete!");
/*     */     }
/*     */     catch (SoapFaultException sfe)
/*     */     {
/* 898 */       checkSoapReason(sfe, "permission denied: can not access distribution list ");
/*     */     }
/*     */   }
/*     */   
/*     */   public static void main(String[] args) throws Exception
/*     */   {
/* 904 */     TestUtil.cliSetup();
/* 905 */     TestUtil.runTest(TestDomainAdmin.class);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestDomainAdmin.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */